package com.bmw.seed.service.impl;

import com.bmw.seed.dao.UserInfoDao;
import com.bmw.seed.model.UserInfo;
import com.bmw.seed.service.UserInfoService;
import com.bmw.seed.util.bean.CursorPageReq;
import com.bmw.seed.util.bean.CursorPageResp;
import com.bmw.seed.util.bean.PageResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Classname: UserInfoServiceImpl
 * Package: com.bmw.seed.service.impl
 * Description:
 *
 * @Author 王少伟
 * @Create 2024/1/29 17:47
 * @Version 1.8
 */
@Service("userInfoService")
@Slf4j
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    UserInfoDao userInfoDao;

    @Override
    public CursorPageResp<UserInfo> cursorPage(CursorPageReq req) {
      log.info("===[开始请求游标分页查询:请求每页数量{},游标值为{}]===",req.getPageSize(),req.getCursor());
      if(req.getCursor() == null){
          //请求第一页
      }
        List<UserInfo> list = userInfoDao.listForCursorPage(req);
      CursorPageResp resp = new CursorPageResp();
      if(list.size() > 0){
          resp.setList(list);
          resp.setCursor(list.get(list.size() - 1).getId());
      }
        return resp;
    }
}
